<template name="localemap">
    <view class="content">
		<cu-custom bgColor="bg-gradual-green" :isBack="false"><block slot="content">位置信息</block></cu-custom>
        <map id="maps" :latitude="latitude" :longitude="longitude" scale="18" style="width: 100%;height: 75vh;"></map>
    </view>
</template>

<script>
export default {
    data() {
        return {
            latitude: '',
            longitude: '',
        };
    },
    mounted() {
        this.getlocal();
    },
    methods: {
        getlocal() {
            const _this = this;
            let map = uni.createMapContext('maps', this).$getAppMap();
            map.showUserLocation(true);
            setInterval(() => {
                uni.getLocation({
                    type: 'gcj02',
                    success: res => {
                        _this.longitude = res.longitude;
                        _this.latitude = res.latitude;
                    }
                });
            }, 1000);
        },
    }
};
</script>

<style scoped lang="scss">
.content {
    position: absolute;
    width: 100%;
    height: 100%;

    #maps {
        width: 100%;
        height: 100%;
    }
}
</style>
